package com.mentalsurvey.mapper;

import com.mentalsurvey.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {
    // 根据名字查找
    @Select("select * from user where username = #{username}")
    User getUserById(String username);

    // 插入新用户
    @Insert("INSERT INTO user (username, password) VALUES (#{username}, #{password})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int register(User user);
}
